﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using MyFloridaHouse.DataAccess.Extensions;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.DataAccess
{
    public partial class DAL_CensusData
    {
        
		/// <summary>
		/// Gets the census geometry from the database.
		/// Returns a collection of pointers (ID  fields) to layer data as a list of: <see cref="CensusGeometryDTO"/>.
		/// </summary>
		/// <returns>List of <see cref="CensusGeometryDTO"/></returns>
		/// <remarks>SPROC: usp_GetCensusGeometry</remarks>
        public List<CensusGeometryDTO> GetCensusGeometry()
        {
            List<CensusGeometryDTO> itemList = new List<CensusGeometryDTO>();

            //string storedProcedureName = "usp_GetCensusGeometry";
            string storedProcedureName = "usp_tl10GetCensusGeometry10";

            using (SqlConnection db = Connect())
            {
                SqlCommand StoredProcedureCommand = new SqlCommand(storedProcedureName, db);
                StoredProcedureCommand.CommandType = CommandType.StoredProcedure;
                StoredProcedureCommand.CommandTimeout = 60000;

                db.Open();
                using (SqlDataReader rdr = StoredProcedureCommand.ExecuteReader())
                {
                    while (rdr.Read() )
                    {
                        itemList.Add(CensusGeometryDTODataContract.DataContract(rdr));
                    }
                }
            }

            return itemList;
        }
    }
}
